﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartWMS.Common.ResponseOutput;
using SmartWMS.Server.StatementServer.StartEndServer;
using SmartWMS.Server.StatementServer.StartEndServer.Dto;

namespace SmartWMS.API.Controllers.StatementMange
{
	/// <summary>
	/// 期初期末控制器
	/// </summary>
	[Route("api/[controller]/[action]")]
	[ApiController]
	[ApiExplorerSettings(GroupName = "Statement")]
	public class StartendController : ControllerBase
	{
		private readonly IStartEndServer _startEndServer;

		public StartendController(IStartEndServer startEndServer)
		{
			_startEndServer = startEndServer;
		}

		/// <summary>
		/// 显示期初期末
		/// </summary>
		/// <param name="dto">要查询的条件</param>
		/// <returns></returns>
		[HttpPost]
		public IActionResult GetStartEndDtoAsync(SearchDataStartendDto dto)
		{
			try
			{
				var list = _startEndServer.GetStartEndDtoAsync(dto);
				return Ok(new
				{
					list.Result.totalCount,
					list.Result.pageCount,
					data = list.Result.data
				});
			}
			catch (Exception)
			{
				throw;
			}
		}
	}
}
